package com.ee.chat.admin.controller.usermanage;

import com.ee.chat.admin.service.IHostService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("host")
public class HostController {
    private Logger log = LoggerFactory.getLogger(HostController.class);

    @Resource
    IHostService hostService;

    /**
     * 获取主播列表
     * @Author Shane
     * @Date 2019/9/1719:20
     * @param online    在线状态
     * @param title     主播头衔
     * @param keyword    搜索关键字
     * @return
     **/
    @RequestMapping("list")
    public Result list(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit,
                       Integer online, Integer title, String keyword, String time){
        try {
            return hostService.list(request, page, limit, online, title, keyword, time);
        } catch (Exception e){
            log.error("【获取主播列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 更新主播等级或权重
     * @Author Shane
     * @Date 2019/12/26 11:07
     * @param
     * @return
     **/
    @RequestMapping("updateLevel")
    public Result updateLevel(HttpServletRequest request, @RequestParam Integer id, Integer level, Integer wi){
        try {
            return hostService.updateLevel(request, id, level, wi);
        } catch (Exception e){
            log.error("【更新主播等级或权重错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 更新主播头衔
     * @Author Shane
     * @Date 2019/12/26 11:11
     * @param
     * @return
     **/
    @RequestMapping("updateTitle")
    public Result updateTitle(HttpServletRequest request, @RequestParam Integer userId, Integer title){
        try {
            return hostService.updateTitle(request, userId, title);
        } catch (Exception e){
            log.error("【更新主播头衔错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 取消认证
     * @Author Shane
     * @Date 2020/6/17 15:38
     * @param
     * @return
     */
    @RequestMapping("cancelAudit")
    public Result cancelAudit(HttpServletRequest request, @RequestParam Integer userId){
        try {
            return hostService.cancelAudit(request, userId);
        } catch (Exception e){
            log.error("【编辑备注错误】", e);
        }
        return Result.returnFailure();
    }
}
